﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace newTurtle8
{
    public partial class CompanyCard : UserControl
    {
        public CompanyCard()
        {
            InitializeComponent();
            this.Dock = DockStyle.Fill;

            //associating an object with each button.
            buttonMatzal.Tag = new MatzalView(this);
            buttonPakalim.Tag = new OccupationView(this);
            buttonEquipment.Tag = new GearView(this);
            buttonTahasukaCapability.Tag = new CompanyTahasukaAbilityPanel(this);
            buttonWarCapability.Tag = new CompanyWarAbilityPanel(this);
            buttonMain.Tag = new CompanyMainPanel();

            changeMainPanelEvent(buttonMain, EventArgs.Empty);
        }

        private void changeMainPanelEvent(object sender, EventArgs e)
        {
            Control button = (Control)sender;
            Control ctrl = (Control)button.Tag;

            if (!splitContainer.Panel1.Controls.Contains(ctrl))
            {
                /*if (ctrl.GetType().Equals(cGearPanel.GetType()))
                    cGearPanel.refresh();*/

                splitContainer.Panel1.Controls.Clear();
                splitContainer.Panel1.Controls.Add(ctrl);

                textBoxTopBar.Text = "כרטיס פלוגה - " + button.Text;
            }

        }

        public void refresh()
        {
            if (this.Visible)
            {
                MatzalView cMatzalPanel = (MatzalView)buttonMatzal.Tag;
                cMatzalPanel.refresh();

            }
        }

    }
}
